<template>
    <input type="text">
    <button @click="handleAdd">点击</button>
</template>
<script setup>
import {ref ,defineEmits} from "vue"

//声明一个自定义事件 完成子传父

let val = ref('')

let emit = defineEmits(['add'])

let handleAdd = () => {
    emit('add',val.value)
}
</script>